	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
	<tr valign="top">
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td><hr align="left" color="#89a00f" width="100%" /></td>
	</tr>
	</tbody>
	</table>
<span class="topic">ฐานข้อมูลประเภทหนังสือส่ง</span>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
	<tr valign="top">
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td width="20"><hr align="left" color="#89a00f" width="70%" /></td>
		<td><hr align="left" color="#89a00f" width="100%" /></td>
	</tr>
	</tbody>
	</table><br />

<?php
	if(isset($_POST['adddoctypesent'])){
		$d = get_depart_name($_POST['depart_id']);
		$r = add_doctypesent($_POST['doctypesent_name'],$_POST['depart_id'],$d);
		if($r==-1) echo "<span class=\"err\">ERROR : ไม่สามารถเพิ่มประเภทหนังสือส่ง <span class=\"topic\">".$_POST['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$d."</span> ได้</span><br /><br />";
		else echo "เพิ่มประเภทหนังสือส่ง <span class=\"topic\">".$_POST['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$d."</span> เรียบร้อยแล้ว<br /><br />";
	}
	else if($_GET['comm']=="del"){
		$r = del_doctypesent($_GET['doctypesent_id'],$_GET['doctypesent_name'],$_GET['depart']);
		if($r==-1) echo "<span class=\"err\">ERROR : ไม่สามารถลบประเภทหนังสือส่ง <span class=\"topic\">".$_GET['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$_GET['depart']."</span> ได้</span><br /><br />";
		else echo "ลบประเภทหนังสือส่ง <span class=\"topic\">".$_GET['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$_GET['depart']."</span> เรียบร้อยแล้ว<br /><br />";
	}
	else if(isset($_POST['editdoctypesent'])){
		$r = edit_doctypesent($_POST['doctypesent_id'],$_POST['doctypesent_name'],$_POST['doctypesent_name_old'],$_POST['depart']);
		if($r==-1) echo "<span class=\"err\">ERROR : ไม่สามารถแก้ไขประเภทหนังสือส่ง <span class=\"topic\">".$_POST['doctypesent_name_old']." </span> ไปเป็น <span class=\"topic\">".$_POST['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$_POST['depart']." </span>ได้</span><br /><br />";
		else echo "แก้ไขประเภทหนังสือส่ง <span class=\"topic\">".$_POST['doctypesent_name_old']." </span> ไปเป็น <span class=\"topic\">".$_POST['doctypesent_name']." </span>ในหน่วยงาน <span class=\"topic\">".$_POST['depart']." </span>เรียบร้อยแล้ว<br /><br />";
	}

?>

<table cellpadding="5" cellspacing="0" border="0" width="100%">
<tr><td>
<form action="update.php" method="post" id="doctypesent_form">
<input type="hidden" name="domain" value="doctype_sent">

<table cellpadding="5" cellspacing="0" border="0">
<tr><td>หน่วยงาน</td><td>:</td><td>
<?php 
	if(!isset($_POST['editdoctypesent']) & !isset($_POST['listdoctypesent']) & !isset($_POST['adddoctypesent']) & ($_GET['comm']!="del") & ($_GET['comm']!="edit")) list_department_user(0,"doctypesent_form"); 
	else if(($_GET['comm']=="del") | ($_GET['comm']=="edit"))	list_department_user(get_depart_id($_GET['depart']),"doctypesent_form");
	else list_department_user($_POST['depart_id'],"doctypesent_form");
?>
</td></tr>
</table>

<input type="hidden" name="listdoctypesent" value="แสดงประเภทหนังสือส่ง">
</form>
<br />

<?php
	if(!isset($_POST['editdoctypesent']) & !isset($_POST['listdoctypesent']) & !isset($_POST['adddoctypesent']) & ($_GET['comm']!="del") & ($_GET['comm']!="edit")) list_doctypesent(0);
	else if(($_GET['comm']=="del") | ($_GET['comm']=="edit")) list_doctypesent(get_depart_id($_GET['depart']));
	else list_doctypesent($_POST['depart_id']);
?>

</td><td valign="top" style="border-left: 3px dotted #89A00F">

<?php
if($_GET['comm']=="edit"){
?>
<form action="update.php" method="post">
<input type="hidden" name="domain" value="doctype_sent">
<input type="hidden" name="doctypesent_id" value="<?php echo $_GET['doctypesent_id']; ?>">
<input type="hidden" name="depart" value="<?php echo $_GET['depart']; ?>">
<input type="hidden" name="doctypesent_name_old" value="<?php echo $_GET['doctypesent_name']; ?>">
<table>
<tr><td>ประเภทหนังสือส่ง</td><td>:</td><td><input type="text" name="doctypesent_name" value="<?php echo $_GET['doctypesent_name']; ?>" size="30" maxlength="450"></td></tr>
<tr><td>หน่วยงาน</td><td>:</td><td><span class="topic">
<?php 
	if(!isset($_POST['editdoctypesent']) & !isset($_POST['listdoctypesent']) & !isset($_POST['adddoctypesent']) & ($_GET['comm']!="del") & ($_GET['comm']!="edit")) list_department_userX(0); 
	else if(($_GET['comm']=="del") | ($_GET['comm']=="edit"))	list_department_userX(get_depart_id($_GET['depart']));
	else list_department_userX($_POST['depart_id']);
?></span>
</td></tr>
<tr><td colspan="2"></td><td><input type="submit" name="editdoctypesent" value=" แก้ไขประเภทหนังสือส่ง "></td></tr>
</table>
</form>
<?php
}else{
?>
<form action="update.php" method="post">
<input type="hidden" name="domain" value="doctype_sent">
<table>
<tr><td>ประเภทหนังสือส่ง</td><td>:</td><td><input type="text" name="doctypesent_name" size="30" maxlength="450"></td></tr>
<tr><td>หน่วยงาน</td><td>:</td><td><span class="topic">
<?php 
	if(!isset($_POST['editdoctypesent']) & !isset($_POST['listdoctypesent']) & !isset($_POST['adddoctypesent']) & ($_GET['comm']!="del") & ($_GET['comm']!="edit")) list_department_userX(0); 
	else if(($_GET['comm']=="del") | ($_GET['comm']=="edit"))	list_department_userX(get_depart_id($_GET['depart']));
	else list_department_userX($_POST['depart_id']);
?></span>
</td></tr>
<tr><td colspan="2"></td><td><input type="submit" name="adddoctypesent" value=" บันทึกประเภทหนังสือส่ง "></td></tr>
</table>
</form>
<?php
}
?>
</td></tr>
</table>
